package org.water.base.entity;


import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import org.hibernate.annotations.GenericGenerator;
/***
 * 实体抽象类，其他实体需要继承该类
 * @author qzy
 *
 */
@MappedSuperclass
public abstract class IdEntity extends AbstractEntity<String> {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public IdEntity() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * id自动生成
	 */
	@Id
	@GeneratedValue(generator="idGenerator")
	@GenericGenerator(name="idGenerator", strategy="org.hibernate.id.UUIDGenerator")
	@Column(name="id",nullable=false)
	private String id;

	@Override
    public String getId() {
		if("".equals(id)) id=null;
        return id;
    }
	
    @Override
    public void setId(String id) {
        this.id = id;
    }

}
